package com.chenfan.mcn.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chenfan.mcn.extension.Res;
import com.chenfan.mcn.model.dto.LiveSettlementCommodityDto;
import com.chenfan.mcn.model.vo.LiveContractCommodityVo;
import com.chenfan.mcn.model.vo.LiveSettlementCommodityExportVo;
import com.chenfan.mcn.service.LiveSettlementCommodityService;
import com.chenfan.privilege.common.config.SearchAuthority;
import com.chenfan.privilege.common.config.UrlAuth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * 直播结算商品
 *
 * @author liuming
 * @date 2023-04-28 9:55
 */
@RestController
@RequestMapping("/liveSettlementCommodity")
public class LiveSettlementCommodityController {

    @Autowired
    private LiveSettlementCommodityService liveSettlementCommodityService;

    /**
     * 导出结算商品
     *
     * @param dto
     * @param response
     * @return
     */
    @PostMapping("/exportSettlementExcel")
    @UrlAuth({"liveProductManagement_settleExport"})
    public Res<Boolean> exportSettlementExcel(@SearchAuthority(filterCustomer = false)  LiveSettlementCommodityDto dto, HttpServletResponse response) {
        liveSettlementCommodityService.exportSettlementExcel(dto, response);
        return Res.ok(true);
    }

    /**
     * 导出直播商品
     *
     * @param dto
     * @param response
     * @return
     */
    @PostMapping("/exportExcel")
    @UrlAuth({"liveProductManagement_liveExport"})
    public Res<Boolean> exportExcel(@SearchAuthority(filterCustomer = false)  LiveSettlementCommodityDto dto, HttpServletResponse response) {
        liveSettlementCommodityService.exportExcel(dto, response);
        return Res.ok(true);
    }

    /**
     * 查询直播列表-分页
     *
     * @param dto
     * @return
     */
    // @PostMapping("/page")
    // public Res<Page<LiveContractCommodityVo>> page(@RequestBody LiveSettlementCommodityDto dto) {
    //     return Res.ok(liveSettlementCommodityService.page(dto));
    // }

    /**
     * 查询直播列表-分页
     *
     * @param dto
     * @return
     */
    @PostMapping("/page")
    public Res<Page<LiveSettlementCommodityExportVo>> page(@RequestBody LiveSettlementCommodityDto dto) {
        return Res.ok(liveSettlementCommodityService.pageV2(dto));
    }

    /**
     * 查询直播商品详情
     *
     * @param lccId
     * @return
     */
    @GetMapping("/detail")
    public Res<LiveContractCommodityVo> detail(@RequestParam("lccId") Long lccId) {
        return Res.ok(liveSettlementCommodityService.detail(lccId));
    }
}
